<template>
  <div class="blog-container">
    <el-card class="blog-card">
      <div class="filter-box">
        <div style="display: inline-block">
          <el-button type="primary">添加</el-button>
        </div>
        <div class="filter-region">
          <el-form :inline="true" :model="filter" class="demo-form-inline">
            <el-form-item label="一级类型">
              <el-input v-model="filter.type" placeholder="请输入内容" />
            </el-form-item>
            <el-form-item label="创建时间">
              <el-date-picker
                v-model="dateList"
                type="datetimerange"
                range-separator="至"
                start-placeholder="开始日期"
                end-placeholder="结束日期"
                value-format="yyyy-MM-dd"
                format="yyyy-MM-dd"
                @change="changeDataFormat"
              />
            </el-form-item>
            <el-form-item>
              <el-button type="primary" @click="fetch">查询</el-button>
            </el-form-item>
          </el-form>
        </div>
      </div>
      <div class="card-list">
        <el-table
          :data="items"
          style="width: 100%;margin-bottom: 20px;"
          row-key="id"
          :default-expand-all="false"
          :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
        >
          <el-table-column
            prop="type"
            label="类型"
            sortable
            min-width="15%"
          />
          <el-table-column
            prop="remark"
            label="备注"
            sortable
            show-overflow-tooltip
            min-width="40%"
          />
          <el-table-column
            prop="createDate"
            label="创建日期"
            sortable
            min-width="15%"
          />
          <el-table-column
            prop="createName"
            label="创建人"
            sortable
            min-width="10%"
          />
          <el-table-column
            fixed="right"
            label="操作"
            min-width="20%"
          >
            <template slot-scope="scope">
              <el-button v-if="scope.row.level !== '3'" type="text" size="small">追加</el-button>
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          background
          layout="prev, pager, next"
          :page-size="pagination.size"
          :current-page="pagination.current"
          :total="pagination.total"
          @current-change="fetch"
        />
      </div>
    </el-card>
  </div>
</template>

<script>

export default {
  data() {
    return {
      dateList: [],
      items: [],
      filter: {
      },
      pagination: {
        current: 1,
        size: 10,
        total: 0
      }
    }
  },
  created() {
  },
  methods: {
    // 日期格式转换
    changeDataFormat(value) {
      this.filter.startTime = value ? `${value[0]} 00:00:00` : ''
      this.filter.endTime = value ? `${value[1]} 23:59:59` : ''
    }
  }
}
</script>

<style lang="scss" scoped>
.blog {
  &-container {
    font-size: 30px;
    min-height: calc(96vh);
    background: #f2f3f7;
    position: relative;
  }
  &-card {
    margin: 2vh 1vh 0 1vh;
  }
}
.filter{
  &-box {
    border-bottom: 1px solid #ccc;
    width: 100%;
  }
  &-region {
    display: inline-block;
    margin-left: 2vh;
  }
}
</style>
